package com.example.graph.repository;

import com.example.graph.entity.UserNode;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * @ClassName: UserRepository
 * @Description:
 * @Author: keke
 * @Date: 2021/6/7 11:24
 */
@Repository
public interface UserRepository extends Neo4jRepository<UserNode,Long> {

//    @Query("MATCH (n:User) RETURN n ")
//    List<UserNode> getUserNodeList();

//    @Query("create (n:User{name:{name},age:{age},sex:{sex}}) RETURN n ")
//    UserNode addUserNode(@Param("name") String name, @Param("age")int age, @Param("sex") String sex);

    @Query("MATCH (n) WHERE id(n) = :#{#userNode.nodeId} SET n.name = :#{#userNode.name},n.age = :#{#userNode.age},n.sex = :#{#userNode.sex} RETURN n")
    UserNode updateByNode(@Param("userNode") UserNode userNode);

}

